<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The NumberFormatter class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="collator.sort.html">« Collator::sort</a></li>
      <li style="float: right;"><a href="numberformatter.create.html">NumberFormatter::create »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.intl.html">intl</a></li>
    <li>The NumberFormatter class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.numberformatter" class="reference">
 <h1 class="title">The NumberFormatter class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL intl &gt;= 1.0.0)</p>

  
  <div class="section" id="numberformatter.intro">
   <h2 class="title">简介</h2>
   <p class="simpara">
    Programs store and operate on numbers using a locale-independent binary
    representation. When displaying or printing a number it is converted to a
    locale-specific string. For example, the number 12345.67 is &quot;12,345.67&quot; in
    the US, &quot;12 345,67&quot; in France and &quot;12.345,67&quot; in Germany.
   </p>
   <p class="simpara">
    By invoking the methods provided by the NumberFormatter class, you can
    format numbers, currencies, and percentages according to the specified or
    default locale. NumberFormatter is locale-sensitive so you need to create
    a new NumberFormatter for each locale. NumberFormatter methods format
    primitive-type numbers, such as double and output the number as a
    locale-specific string.
   </p>
   <p class="para">
    For currencies you can use currency format type to create a formatter that
    returns a string with the formatted number and the appropriate currency
    sign. Of course, the NumberFormatter class is unaware of exchange rates
    so, the number output is the same regardless of the specified currency.
    This means that the same number has different monetary values depending on
    the currency locale. If the number is 9988776.65 the results will be:
    <ul class="simplelist">
     <li class="member">9 988 776,65 € in France</li>
     <li class="member">9.988.776,65 € in Germany</li>
     <li class="member">$9,988,776.65 in the United States</li>
    </ul>
   </p>
   <p class="simpara">
    In order to format percentages, create a locale-specific formatter with
    percentage format type. With this formatter, a decimal fraction such as
    0.75 is displayed as 75%.
   </p>
   <p class="simpara">
    For more complex formatting, like spelled-out numbers, the rule-based
    number formatters are used.
   </p>
  </div>
  

  <div class="section" id="numberformatter.synopsis">
   <h2 class="title">类摘要</h2>

   
   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">NumberFormatter</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="numberformatter.create.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$style</code></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$pattern</code><span class="initializer"> = <strong><code>null</code></strong></span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="numberformatter.create.html" class="methodname">create</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$style</code></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$pattern</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">?</span><span class="type"><a href="class.numberformatter.html" class="type NumberFormatter">NumberFormatter</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.formatcurrency.html" class="methodname">formatCurrency</a></span>(<span class="methodparam"><span class="type">float</span> <code class="parameter">$amount</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$currency</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.format.html" class="methodname">format</a></span>(<span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">float</span></span> <code class="parameter">$num</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = NumberFormatter::TYPE_DEFAULT</span></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.getattribute.html" class="methodname">getAttribute</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>): <span class="type"><span class="type">int</span>|<span class="type">float</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.geterrorcode.html" class="methodname">getErrorCode</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.geterrormessage.html" class="methodname">getErrorMessage</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.getlocale.html" class="methodname">getLocale</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = <strong><code>ULOC_ACTUAL_LOCALE</code></strong></span></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.getpattern.html" class="methodname">getPattern</a></span>(): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.getsymbol.html" class="methodname">getSymbol</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$symbol</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.gettextattribute.html" class="methodname">getTextAttribute</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.parsecurrency.html" class="methodname">parseCurrency</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$currency</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$offset</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">float</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.parse.html" class="methodname">parse</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = NumberFormatter::TYPE_DOUBLE</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$offset</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">int</span>|<span class="type">float</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.setattribute.html" class="methodname">setAttribute</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">float</span></span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.setpattern.html" class="methodname">setPattern</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.setsymbol.html" class="methodname">setSymbol</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$symbol</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="numberformatter.settextattribute.html" class="methodname">setTextAttribute</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>

   }</div>
   

  </div>

  

  

<div class="section" id="intl.numberformatter-constants">
 <h2 class="title">预定义常量</h2>

 <div class="section" id="intl.numberformatter-constants.unumberformatstyle">
  <p class="para">
   These styles are used by the <span class="function"><a href="numberformatter.create.html" class="function">numfmt_create()</a></span>
   to define the type of the formatter.
   <dl>
    
     <dt id="numberformatter.constants.pattern-decimal">
      <strong><code>NumberFormatter::PATTERN_DECIMAL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Decimal format defined by pattern</span>
     </dd>

    

    
     <dt id="numberformatter.constants.decimal">
      <strong><code>NumberFormatter::DECIMAL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Decimal format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.currency">
      <strong><code>NumberFormatter::CURRENCY</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Currency format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.percent">
      <strong><code>NumberFormatter::PERCENT</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Percent format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.scientific">
      <strong><code>NumberFormatter::SCIENTIFIC</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Scientific format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.spellout">
      <strong><code>NumberFormatter::SPELLOUT</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Spellout rule-based format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.ordinal">
      <strong><code>NumberFormatter::ORDINAL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Ordinal rule-based format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.duration">
      <strong><code>NumberFormatter::DURATION</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Duration rule-based format</span>
     </dd>

    

    
     <dt id="numberformatter.constants.pattern-rulebased">
      <strong><code>NumberFormatter::PATTERN_RULEBASED</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rule-based format defined by pattern</span>
     </dd>

    

    
     <dt id="numberformatter.constants.currency-accounting">
      <strong><code>NumberFormatter::CURRENCY_ACCOUNTING</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       Currency format for accounting, e.g., <code class="literal">($3.00)</code> for negative currency amount
       instead of <code class="literal">-$3.00</code>. Available as of PHP 7.4.1 and ICU 53.
      </span>
     </dd>

    

    
     <dt id="numberformatter.constants.default-style">
      <strong><code>NumberFormatter::DEFAULT_STYLE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Default format for the locale</span>
     </dd>

    

    
     <dt id="numberformatter.constants.ignore">
      <strong><code>NumberFormatter::IGNORE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Alias for PATTERN_DECIMAL</span>
     </dd>

    
   </dl>






  </p>
 </div>

 <div class="section" id="intl.numberformatter-constants.types">
  <p class="para">
   These constants define how the numbers are parsed or formatted. They should
   be used as arguments to <span class="function"><a href="numberformatter.format.html" class="function">numfmt_format()</a></span>
   and <span class="function"><a href="numberformatter.parse.html" class="function">numfmt_parse()</a></span>.
   <dl>
    
     <dt id="numberformatter.constants.type-default">
      <strong><code>NumberFormatter::TYPE_DEFAULT</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Derive the type from variable type</span>
     </dd>

    

    
     <dt id="numberformatter.constants.type-int32">
      <strong><code>NumberFormatter::TYPE_INT32</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Format/parse as 32-bit integer</span>
     </dd>

    

    
     <dt id="numberformatter.constants.type-int64">
      <strong><code>NumberFormatter::TYPE_INT64</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Format/parse as 64-bit integer</span>
     </dd>

    

    
     <dt id="numberformatter.constants.type-double">
      <strong><code>NumberFormatter::TYPE_DOUBLE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Format/parse as floating point value</span>
     </dd>

    

    
     <dt id="numberformatter.constants.type-currency">
      <strong><code>NumberFormatter::TYPE_CURRENCY</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Format/parse as currency value</span>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="section" id="intl.numberformatter-constants.unumberformatattribute">
  <p class="para">
   Number format attribute used by
   <span class="function"><a href="numberformatter.getattribute.html" class="function">numfmt_get_attribute()</a></span>
   and
   <span class="function"><a href="numberformatter.setattribute.html" class="function">numfmt_set_attribute()</a></span>.
   <dl>
    
     <dt id="numberformatter.constants.parse-int-only">
      <strong><code>NumberFormatter::PARSE_INT_ONLY</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Parse integers only.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.grouping-used">
      <strong><code>NumberFormatter::GROUPING_USED</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Use grouping separator.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.decimal-always-shown">
      <strong><code>NumberFormatter::DECIMAL_ALWAYS_SHOWN</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Always show decimal point.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.max-integer-digits">
      <strong><code>NumberFormatter::MAX_INTEGER_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Maximum integer digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.min-integer-digits">
      <strong><code>NumberFormatter::MIN_INTEGER_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Minimum integer digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.integer-digits">
      <strong><code>NumberFormatter::INTEGER_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Integer digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.max-fraction-digits">
      <strong><code>NumberFormatter::MAX_FRACTION_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Maximum fraction digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.min-fraction-digits">
      <strong><code>NumberFormatter::MIN_FRACTION_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Minimum fraction digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.fraction-digits">
      <strong><code>NumberFormatter::FRACTION_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Fraction digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.multiplier">
      <strong><code>NumberFormatter::MULTIPLIER</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Multiplier.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.grouping-size">
      <strong><code>NumberFormatter::GROUPING_SIZE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Grouping size.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.rounding-mode">
      <strong><code>NumberFormatter::ROUNDING_MODE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rounding Mode.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.rounding-increment">
      <strong><code>NumberFormatter::ROUNDING_INCREMENT</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rounding increment.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.format-width">
      <strong><code>NumberFormatter::FORMAT_WIDTH</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The width to which the output of format() is padded.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.padding-position">
      <strong><code>NumberFormatter::PADDING_POSITION</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       The position at which padding will take place. See pad position
       constants for possible argument values.
      </span>
     </dd>

    

    
     <dt id="numberformatter.constants.secondary-grouping-size">
      <strong><code>NumberFormatter::SECONDARY_GROUPING_SIZE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Secondary grouping size.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.significant-digits-used">
      <strong><code>NumberFormatter::SIGNIFICANT_DIGITS_USED</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Use significant digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.min-significant-digits">
      <strong><code>NumberFormatter::MIN_SIGNIFICANT_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Minimum significant digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.max-significant-digits">
      <strong><code>NumberFormatter::MAX_SIGNIFICANT_DIGITS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Maximum significant digits.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.lenient-parse">
      <strong><code>NumberFormatter::LENIENT_PARSE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Lenient parse mode used by rule-based formats.</span>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="section" id="intl.numberformatter-constants.unumberformattextattribute">
  <p class="para">
   Number format text attribute used by
   <span class="function"><a href="numberformatter.gettextattribute.html" class="function">numfmt_get_text_attribute()</a></span> and
   <span class="function"><a href="numberformatter.settextattribute.html" class="function">numfmt_set_text_attribute()</a></span>.
   <dl>
    
     <dt id="numberformatter.constants.positive-prefix">
      <strong><code>NumberFormatter::POSITIVE_PREFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Positive prefix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.positive-suffix">
      <strong><code>NumberFormatter::POSITIVE_SUFFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Positive suffix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.negative-prefix">
      <strong><code>NumberFormatter::NEGATIVE_PREFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Negative prefix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.negative-suffix">
      <strong><code>NumberFormatter::NEGATIVE_SUFFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Negative suffix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.padding-character">
      <strong><code>NumberFormatter::PADDING_CHARACTER</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The character used to pad to the format width.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.currency-code">
      <strong><code>NumberFormatter::CURRENCY_CODE</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The ISO currency code.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.default-ruleset">
      <strong><code>NumberFormatter::DEFAULT_RULESET</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       The default rule set. This is only available with rule-based
       formatters.
      </span>
     </dd>

    

    
     <dt id="numberformatter.constants.public-rulesets">
      <strong><code>NumberFormatter::PUBLIC_RULESETS</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       The public rule sets. This is only available with rule-based
       formatters. This is a read-only attribute. The public rulesets are
       returned as a single string, with each ruleset name delimited by &#039;;&#039;
       (semicolon).
      </span>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="section" id="intl.numberformatter-constants.unumberformatsymbol">
  <p class="para">
   Number format symbols used by <span class="function"><a href="numberformatter.getsymbol.html" class="function">numfmt_get_symbol()</a></span>
   and <span class="function"><a href="numberformatter.setsymbol.html" class="function">numfmt_set_symbol()</a></span>.
   <dl>
    
     <dt id="numberformatter.constants.decimal-separator-symbol">
      <strong><code>NumberFormatter::DECIMAL_SEPARATOR_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The decimal separator.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.grouping-separator-symbol">
      <strong><code>NumberFormatter::GROUPING_SEPARATOR_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The grouping separator.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.pattern-separator-symbol">
      <strong><code>NumberFormatter::PATTERN_SEPARATOR_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The pattern separator.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.percent-symbol">
      <strong><code>NumberFormatter::PERCENT_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The percent sign.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.zero-digit-symbol">
      <strong><code>NumberFormatter::ZERO_DIGIT_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Zero.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.digit-symbol">
      <strong><code>NumberFormatter::DIGIT_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Character representing a digit in the pattern.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.minus-sign-symbol">
      <strong><code>NumberFormatter::MINUS_SIGN_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The minus sign.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.plus-sign-symbol">
      <strong><code>NumberFormatter::PLUS_SIGN_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The plus sign.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.currency-symbol">
      <strong><code>NumberFormatter::CURRENCY_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The currency symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.intl-currency-symbol">
      <strong><code>NumberFormatter::INTL_CURRENCY_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The international currency symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.monetary-separator-symbol">
      <strong><code>NumberFormatter::MONETARY_SEPARATOR_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The monetary separator.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.exponential-symbol">
      <strong><code>NumberFormatter::EXPONENTIAL_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The exponential symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.permill-symbol">
      <strong><code>NumberFormatter::PERMILL_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Per mill symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.pad-escape-symbol">
      <strong><code>NumberFormatter::PAD_ESCAPE_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Escape padding character.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.infinity-symbol">
      <strong><code>NumberFormatter::INFINITY_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Infinity symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.nan-symbol">
      <strong><code>NumberFormatter::NAN_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Not-a-number symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.significant-digit-symbol">
      <strong><code>NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Significant digit symbol.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.monetary-grouping-separator-symbol">
      <strong><code>NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">The monetary grouping separator.</span>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="section" id="intl.numberformatter-constants.unumberformatroundingmode">
  <p class="para">
   Rounding mode values used by <span class="function"><a href="numberformatter.getattribute.html" class="function">numfmt_get_attribute()</a></span>
   and <span class="function"><a href="numberformatter.setattribute.html" class="function">numfmt_set_attribute()</a></span> with
   <strong><code>NumberFormatter::ROUNDING_MODE</code></strong> attribute.
   <dl>
    
     <dt id="numberformatter.constants.round-ceiling">
      <strong><code>NumberFormatter::ROUND_CEILING</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rounding mode to round towards positive infinity.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.round-down">
      <strong><code>NumberFormatter::ROUND_DOWN</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rounding mode to round towards zero.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.round-floor">
      <strong><code>NumberFormatter::ROUND_FLOOR</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rounding mode to round towards negative infinity.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.round-halfdown">
      <strong><code>NumberFormatter::ROUND_HALFDOWN</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       Rounding mode to round towards &quot;nearest neighbor&quot; unless both neighbors
       are equidistant, in which case round down.
      </span>
     </dd>

    

    
     <dt id="numberformatter.constants.round-halfeven">
      <strong><code>NumberFormatter::ROUND_HALFEVEN</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       Rounding mode to round towards the &quot;nearest neighbor&quot; unless both
       neighbors are equidistant, in which case, round towards the even
       neighbor.
      </span>
     </dd>

    

    
     <dt id="numberformatter.constants.round-halfup">
      <strong><code>NumberFormatter::ROUND_HALFUP</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">
       Rounding mode to round towards &quot;nearest neighbor&quot; unless both neighbors
       are equidistant, in which case round up.
      </span>
     </dd>

    

    
     <dt id="numberformatter.constants.round-up">
      <strong><code>NumberFormatter::ROUND_UP</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Rounding mode to round away from zero.</span>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="section" id="intl.numberformatter-constants.unumberformatpadposition">
  <p class="para">
   Pad position values used by <span class="function"><a href="numberformatter.getattribute.html" class="function">numfmt_get_attribute()</a></span>
   and <span class="function"><a href="numberformatter.setattribute.html" class="function">numfmt_set_attribute()</a></span> with
   <strong><code>NumberFormatter::PADDING_POSITION</code></strong> attribute.
   <dl>
    
     <dt id="numberformatter.constants.pad-after-prefix">
      <strong><code>NumberFormatter::PAD_AFTER_PREFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Pad characters inserted after the prefix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.pad-after-suffix">
      <strong><code>NumberFormatter::PAD_AFTER_SUFFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Pad characters inserted after the suffix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.pad-before-prefix">
      <strong><code>NumberFormatter::PAD_BEFORE_PREFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Pad characters inserted before the prefix.</span>
     </dd>

    

    
     <dt id="numberformatter.constants.pad-before-suffix">
      <strong><code>NumberFormatter::PAD_BEFORE_SUFFIX</code></strong>
      (<span class="type">int</span>)
     </dt>

     <dd>

      <span class="simpara">Pad characters inserted before the suffix.</span>
     </dd>

    
   </dl>

  </p>
 </div>

</div>





  <div class="section" id="numberformatter.seealso">
   <h2 class="title">参见</h2>
   <p class="para">
    <ul class="simplelist">
     <li class="member">
      <a href="https://unicode-org.github.io/icu/userguide/format_parse/" class="link external">&raquo;&nbsp;
       ICU formatting documentation
      </a>
     </li>
     <li class="member">
      <a href="https://unicode-org.github.io/icu/userguide/format_parse/numbers/" class="link external">&raquo;&nbsp;ICU number formatters</a>
     </li>
     <li class="member">
      <a href="http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details" class="link external">&raquo;&nbsp;ICU decimal formatters</a>
     </li>
     <li class="member">
      <a href="http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#details" class="link external">&raquo;&nbsp;
       ICU rule-based number formatters
      </a>
     </li>
    </ul>
   </p>
  </div>
 </div>

 

















































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="numberformatter.create.html">NumberFormatter::create</a> — Create a number formatter</li><li><a href="numberformatter.formatcurrency.html">NumberFormatter::formatCurrency</a> — Format a currency value</li><li><a href="numberformatter.format.html">NumberFormatter::format</a> — Format a number</li><li><a href="numberformatter.getattribute.html">NumberFormatter::getAttribute</a> — Get an attribute</li><li><a href="numberformatter.geterrorcode.html">NumberFormatter::getErrorCode</a> — Get formatter's last error code</li><li><a href="numberformatter.geterrormessage.html">NumberFormatter::getErrorMessage</a> — Get formatter's last error message</li><li><a href="numberformatter.getlocale.html">NumberFormatter::getLocale</a> — Get formatter locale</li><li><a href="numberformatter.getpattern.html">NumberFormatter::getPattern</a> — Get formatter pattern</li><li><a href="numberformatter.getsymbol.html">NumberFormatter::getSymbol</a> — Get a symbol value</li><li><a href="numberformatter.gettextattribute.html">NumberFormatter::getTextAttribute</a> — Get a text attribute</li><li><a href="numberformatter.parsecurrency.html">NumberFormatter::parseCurrency</a> — Parse a currency number</li><li><a href="numberformatter.parse.html">NumberFormatter::parse</a> — Parse a number</li><li><a href="numberformatter.setattribute.html">NumberFormatter::setAttribute</a> — Set an attribute</li><li><a href="numberformatter.setpattern.html">NumberFormatter::setPattern</a> — Set formatter pattern</li><li><a href="numberformatter.setsymbol.html">NumberFormatter::setSymbol</a> — Set a symbol value</li><li><a href="numberformatter.settextattribute.html">NumberFormatter::setTextAttribute</a> — Set a text attribute</li></ul>
</div>
</div></div></body></html>